//
//  HNSH_HYZIntegralBillHeader.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/7/1.
//

#import "HNSH_HYZIntegralBillHeader.h"

@interface HNSH_HYZIntegralBillHeader ()

/* bgImgV */
@property (nonatomic, strong) UIImageView *bgImgV;
/* titleLabel */
@property (nonatomic, strong) UILabel *titleLabel;
/* moneyLabel */
@property (nonatomic, strong) UILabel *moneyLabel;

/* titleLabel1 */
@property (nonatomic, strong) UILabel *titleLabel1;
/* moneyLabel1 */
@property (nonatomic, strong) UILabel *moneyLabel1;

/* titleLabel2 */
@property (nonatomic, strong) UILabel *titleLabel2;
/* moneyLabel2 */
@property (nonatomic, strong) UILabel *moneyLabel2;

/* selectLine */
@property (nonatomic, strong) UIView *selectLine;
@end

@implementation HNSH_HYZIntegralBillHeader

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self configUI];
    }
    return self;
}

- (void)setZjType:(NSInteger)zjType {
    _zjType = zjType;
    
}

- (void)configZjType:(NSInteger)zjType info:(NSDictionary *)info {
    _dic = info;
    _zjType = zjType;
    
    [self configUI];
    
    self.bgImgV.image = [UIImage imageNamed:@"jf_gwz_bg"];
    
    self.titleLabel.text = [NSString stringWithFormat:@"%@", info[@"main_label"]];
    self.moneyLabel.text = [NSString stringWithFormat:@"%.2f", [info[@"main_value"] doubleValue]];
    
    self.titleLabel1.text = [NSString stringWithFormat:@"%@", info[@"middle_label"]];
    self.moneyLabel1.text = [NSString stringWithFormat:@"%.2f", [info[@"middle_value"] doubleValue]];
    
    self.titleLabel2.text = [NSString stringWithFormat:@"%@", info[@"right_label"]];
    self.moneyLabel2.text = [NSString stringWithFormat:@"%.2f", [info[@"right_value"] doubleValue]];
//    self.jfLabel.text = [NSString stringWithFormat:@"%.2f", [info[@"main_value"] doubleValue]];
//    self.jfTitleLabel.text = [NSString stringWithFormat:@"%@", info[@"main_label"]];
//    self.rightLabel.text = [NSString stringWithFormat:@"%.2f", [info[@"other_value"] doubleValue]];
//    self.rightTitleLabel.text = [NSString stringWithFormat:@"%@", info[@"other_label"]];
}

- (void)configUI {
    [self addSubview:self.bgImgV];
    [self.bgImgV addSubview:self.titleLabel];
    [self.bgImgV addSubview:self.moneyLabel];
    
    [self.bgImgV addSubview:self.titleLabel1];
    [self.bgImgV addSubview:self.moneyLabel1];
    
    [self.bgImgV addSubview:self.titleLabel2];
    [self.bgImgV addSubview:self.moneyLabel2];
    
    [self.bgImgV addSubview:self.selectLine];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(kScreenWidth/3, 68, 1, 16)];
    line.backgroundColor = [UIColor colorWithHexString:@"#FF8787"];
    [self.bgImgV addSubview:line];
    
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(kScreenWidth/3*2, 68, 1, 16)];
    line1.backgroundColor = [UIColor colorWithHexString:@"#FF8787"];
    [self.bgImgV addSubview:line1];
}

#pragma mark lazy
- (UIImageView *)bgImgV {
    if (!_bgImgV) {
        _bgImgV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 154)];
        _bgImgV.userInteractionEnabled = YES;
    }
    return _bgImgV;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 55, kScreenWidth/3, 14)];
        _titleLabel.text = @"团队活跃度";
        _titleLabel.textColor = [UIColor appWhiteLabelColor];
        _titleLabel.font = [UIFont systemFontOfSize:10];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.userInteractionEnabled = YES;
        WeakSelf(weakSelf);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
            weakSelf.selectLine.frame = CGRectMake((kScreenWidth/6)-10, 107, 20, 3);
            if (weakSelf.billBlock) {
                weakSelf.billBlock(0);
            }
        }];
        [_titleLabel addGestureRecognizer:tap];
    }
    return _titleLabel;
}

- (UILabel *)moneyLabel {
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 72, kScreenWidth/3, 28)];
        _moneyLabel.text = @"0.00";
        _moneyLabel.textColor = [UIColor appWhiteLabelColor];
        _moneyLabel.font = [UIFont boldSystemFontOfSize:20];
        _moneyLabel.textAlignment = NSTextAlignmentCenter;
        _moneyLabel.userInteractionEnabled = YES;
        WeakSelf(weakSelf);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
            weakSelf.selectLine.frame = CGRectMake((kScreenWidth/6)-10, 107, 20, 3);
            if (weakSelf.billBlock) {
                weakSelf.billBlock(0);
            }
        }];
        [_moneyLabel addGestureRecognizer:tap];
    }
    return _moneyLabel;
}

- (UILabel *)titleLabel1 {
    if (!_titleLabel1) {
        _titleLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth/3, 55, kScreenWidth/3, 14)];
        _titleLabel1.text = @"加成活跃度";
        _titleLabel1.textColor = [UIColor appWhiteLabelColor];
        _titleLabel1.font = [UIFont systemFontOfSize:10];
        _titleLabel1.textAlignment = NSTextAlignmentCenter;
        _titleLabel1.userInteractionEnabled = YES;
        WeakSelf(weakSelf);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
            weakSelf.selectLine.frame = CGRectMake((kScreenWidth/6)*3-10, 107, 20, 3);
            if (weakSelf.billBlock) {
                weakSelf.billBlock(1);
            }
        }];
        [_titleLabel1 addGestureRecognizer:tap];
    }
    return _titleLabel1;
}

- (UILabel *)moneyLabel1 {
    if (!_moneyLabel1) {
        _moneyLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth/3, 72, kScreenWidth/3, 28)];
        _moneyLabel1.text = @"0.00";
        _moneyLabel1.textColor = [UIColor appWhiteLabelColor];
        _moneyLabel1.font = [UIFont boldSystemFontOfSize:20];
        _moneyLabel1.textAlignment = NSTextAlignmentCenter;
        _moneyLabel1.userInteractionEnabled = YES;
        WeakSelf(weakSelf);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
            weakSelf.selectLine.frame = CGRectMake((kScreenWidth/6)*3-10, 107, 20, 3);
            if (weakSelf.billBlock) {
                weakSelf.billBlock(1);
            }
        }];
        [_moneyLabel1 addGestureRecognizer:tap];
    }
    return _moneyLabel1;
}

- (UILabel *)titleLabel2 {
    if (!_titleLabel2) {
        _titleLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth/3*2, 55, kScreenWidth/3, 14)];
        _titleLabel2.text = @"个人活跃度";
        _titleLabel2.textColor = [UIColor appWhiteLabelColor];
        _titleLabel2.font = [UIFont systemFontOfSize:10];
        _titleLabel2.textAlignment = NSTextAlignmentCenter;
        _titleLabel2.userInteractionEnabled = YES;
        WeakSelf(weakSelf);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
            weakSelf.selectLine.frame = CGRectMake((kScreenWidth/6)*5-10, 107, 20, 3);
            if (weakSelf.billBlock) {
                weakSelf.billBlock(2);
            }
        }];
        [_titleLabel2 addGestureRecognizer:tap];
    }
    return _titleLabel2;
}

- (UILabel *)moneyLabel2 {
    if (!_moneyLabel2) {
        _moneyLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth/3*2, 72, kScreenWidth/3, 28)];
        _moneyLabel2.text = @"0.00";
        _moneyLabel2.textColor = [UIColor appWhiteLabelColor];
        _moneyLabel2.font = [UIFont boldSystemFontOfSize:20];
        _moneyLabel2.textAlignment = NSTextAlignmentCenter;
        _moneyLabel2.userInteractionEnabled = YES;
        WeakSelf(weakSelf);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithActionBlock:^(id  _Nonnull sender) {
            weakSelf.selectLine.frame = CGRectMake((kScreenWidth/6)*5-10, 107, 20, 3);
            if (weakSelf.billBlock) {
                weakSelf.billBlock(2);
            }
        }];
        [_moneyLabel2 addGestureRecognizer:tap];
    }
    return _moneyLabel2;
}

- (UIView *)selectLine {
    if (!_selectLine) {
        _selectLine = [[UIView alloc]initWithFrame:CGRectMake((kScreenWidth/6)-10, 107, 20, 3)];
        _selectLine.backgroundColor = [UIColor appWhiteLabelColor];
        _selectLine.layer.cornerRadius = 1.5f;
        _selectLine.layer.masksToBounds = YES;
    }
    return _selectLine;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
